package ws.jdbc.concurrent.driver.sqlserver

/**
 * Generate test data.
 * 
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
class GenDataTest extends GroovyTestCase {
  /** Path to data file. */
  def path = "test/ws/jdbc/concurrent/driver/sqlserver/"
  /** File name for the test data. */
  def filename = "DataTest.groovy"
  /** Generate random data. */
  def rand = new Random()
  /** Number of rows to be created. */
  def nrows = 50

  void testGen() {
    println "Generating test data..."

    File file = new File(path + filename)

    file.write("package ws.jdbc.concurrent.driver.sqlserver\n\n")
    file.append("class DataTest {\n")
    file.append("  def static table = [\n")
    nrows.times {
      int n = rand.nextInt(1000)
      file.append("    [" + n + ", \"val " + n + "\"],\n")
    }
    file.append("  ] as Object[][]\n")
    file.append("}\n")

    println "Terminated!"
  }
}

